#lang racket

(require "rename-immutable-pair-ops.rkt")

(provide list pair? cons car cdr set-car! set-cdr! append print-list)


(define (ilist->mlist x)
  (if (null? x)
      '()
      (mcons (icar x) (ilist->mlist (icdr x)))))

(define (mlist . x)
  (ilist->mlist x))

(define (append x y)
  (if (null? x)
      y
      (mcons (mcar x) (append (mcdr x) y))))

(define list mlist)

(define pair? mpair?)

(define cons mcons)

(define car mcar)

(define cdr mcdr)

(define set-car! set-mcar!)

(define set-cdr! set-mcdr!)

(define (print-list´ l) 
  (cond ((not (null? l)) (begin (display (mcar l))
                                (cond ((not (null? (mcdr l))) (display ", ")))
                                (print-list´ (mcdr l))))))

(define (print-list l)
  (begin (display "(")
         (print-list´ l)
         (display ")\n")))

(define l (list 'a 'b 'c 'd))











